<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper" ref="mySwiper">
      <swiper-slide v-for="(item, index) of sildePage" :key="index">
        <div class="slide-swiper" v-for="(i, index) of item" :key="index">
          <a :href="i.httpUrl">
            <img class="swiper-img" :src="i.imageUrl" alt="">
            <div class="mask"></div>
          </a>
        </div>
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
import 'swiper/dist/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
  name: 'banner',
  props: {
    sildePage: Array
  },
  components: {
    swiper,
    swiperSlide
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true,
        autoplay: 10000,
        observer: true,
        observeParents: true,
        paginationClickable: true, // 点击小圆点
        direction : 'vertical'
      }
    }
  },
  computed: {
    showSwiper () {
      return this.sildePage.length
    }
  }
}
</script>

<style lang="stylus" scoped>
.wrapper >>> .swiper-container{
  position: relative;
  width: 100%;
  height: 190px;
  overflow: inherit;
}
.wrapper >>> .swiper-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  transition-property: transform;
  box-sizing: content-box;
}
.wrapper >>> .swiper-slide {
  display: flex;
  justify-content: space-between;
  -webkit-flex-shrink: 0;
  -ms-flex: 0 0 auto;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  position: relative;
}
.wrapper >>> .swiper-pagination-bullet{
  display: block;
  width: 4px;
  height: 16px;
  margin: 10px;
  border-radius: 2px;
  opacity: .5;
  background: rgb(255, 255, 255)
  cursor: pointer;
}
.wrapper >>> .swiper-pagination-bullet-active{
  opacity: 1;
  background: rgb(255, 255, 255)
}
.wrapper{
  max-width: 1200px;
  width: 86%;
  margin: 0 auto;
  padding: 0 20px;
  min-width: 1150px;
  height: 200px;
  overflow: hidden;
  .slide-swiper {
    width: 264px;
    height: 156px;
    a {
      position: relative;
      display: block;
      width: 100%;
      height: 100%;
      &:hover {
        .mask { opacity: 1; }
      }
      .swiper-img {
        width: 100%;
        height: 100%;
        border-radius: 5px;
        box-sizing: border-box;
      }
      .mask {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background: url(../../../assets/addImg/home/new-bg.png);
        opacity: 0;
        transition: .3s ease all;
        border-radius: 5px;
      }
    }
  }
  .swiper-pagination {
    position: absolute;
    right: 0;
    top: 50%;
    padding: 10px;
    transition: 300ms;
    transform: translate3d(0, -50%, 0);
    z-index: 10;
  }
}
</style>
